<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      header {
        width: 375px;
        height: 50px;
        background-color: red;
        color: #fff;
        font-size: 20px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    </style>
  </head>
  <body>
    <!-- 
      当一个组件需要被复用很多次，并且显示的内容是不同的
      那么这个不同的内容就应该从父组件传进来
     -->
    <div id="app">
      <h2>猫眼头部组件开发</h2>
      <!-- <my-header title="猫眼电影"></my-header>
      <br />
      <my-header title="人生路不熟"></my-header> -->

      <my-header v-for="item in list" :key="item" :title="item"></my-header>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const MyHeader = {
        props: ["title"],
        template: `
          <header>{{ title }}</header>
        `,
      };

      const app = createApp({
        data() {
          return {
            list: ["猫眼电影", "人生路不熟", "长空之王"],
          };
        },
        components: {
          MyHeader,
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
